package internal.reflect;

import org.lightcommons.json.JSONArray;
import org.lightcommons.json.JSONException;
import org.lightcommons.json.JSONObject;



public class JSON {
	
	public Object toJSON(String src){
		if(isArray(src)){
			try {
				return new JSONArray(src);
			} catch (JSONException e) {
			}
		}else{
			try {
				return new JSONObject(src);
			} catch (JSONException e) {
			}
		}
		return null;
	}
	
	public static JSONArray toJSONArray(String src){
		try {
			return new JSONArray(src);
		} catch (JSONException e) {
		}
		return null;
	}
	public static JSONObject toJSONObject(String src){
		try {
			return new JSONObject(src);
		} catch (JSONException e) {
		}
		return null;
	}
	
	public boolean isArray(String src){
		return src.startsWith("[");
	}
	public boolean isObject(String src){
		return src.startsWith("{");
	}
}
